<template>
	<u-modal :model-value="props.modelValue" title="系统提示" :content="`您已经永久拒绝${props.purviewName}权限，是否要去应用设置中手动打开？`"
		show-cancel-button @confirm="throttle" @cancel="cancel">

	</u-modal>
</template>

<script setup>
	import permision from "@/js_sdk/permission/permission.js"
	import {
		reactive,
		watch
	} from "vue";
	const props = defineProps({
		modelValue: Boolean,
		purviewName: String
	})
	const emit = defineEmits(['cancel'])
	const cancel = () => {
		emit('cancel')
	}
	const throttle = () => {
		uni.$u.throttle(confirm(), 1000)
	}
	const confirm = () => {
		if (uni.$u.os() == 'ios') {
			switch (props.purviewName) {
				case "位置":
					plus.runtime.openURL("app-settings://");
					break;
				case "相册":
					var phphotoLibrary = plus.ios.import("PHPhotoLibrary");
					phphotoLibrary.requestAuthorization(function(status) {
						if (status === 3) {} else {
							plus.runtime.openURL("app-settings://");
						}
					});
					break;
				case "相机":
					plus.runtime.openURL("app-settings://");
					break;
			}
		} else {
			permision.gotoAppPermissionSetting()
		}
		emit('cancel')
	}
</script>

<style>
</style>